/*
 * 加载完后执行
 */
$(function () {
    const Base_Url = "http://127.0.0.1:8080/"; // TODO 问题八 为前端设置后端服务API地址
    const SubmitButton = $("#submitButton");
    const mobile = $("#mobile");
    const carrier = $("#carrier");


    // 验证手机号
    var isPhoneNo = (phone) => {
        var pattern = /^1[34578]\d{9}$/;
        return pattern.test(phone);
    }

    
    /**
     *绑定获取事件
     **/
    SubmitButton.bind("click", () => {

        //手机号码
        let mobileNum = $.trim(mobile.val());
        let carrierValue = carrier.val();
        //简单校验一下
        if (mobileNum.length == 0) {
            alert("请输入手机号");
        } else if (!isPhoneNo(mobileNum)) {
            alert("手机号码不正确");
        }else if(!carrierValue){
            alert("请选择运营商");
        }else{
            $.get(Base_Url + "onlineHour/queryOnlineHour", {mobile: mobileNum,carrier:carrierValue}, (data) => {
                if(data.status == "S"){
                    alert(data.onlineHourInfo.onlineHour)
                }else{
                    alert(data.sysMsg)
                }
             });
        }



    });
});
